package com.situ.config;

import com.situ.interceptor.LoginInterceptor;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@RequiredArgsConstructor
public class WebMvcConfiguration implements WebMvcConfigurer {

    private final LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                //配置拦截的路径
                .addPathPatterns("/**")
                //配置放行的路径
                .excludePathPatterns(
                        "/webjars/**",
                        "/",
                        "/web/**",
                        "/index.html",
                        "/bootstrap3/**",
                        "/css/**",
                        "/js/**",
                        "/images/**",
                        "/user/login",
                        "/user/register",
                        "/user/checkToken",
                        "/product/**",
                        "/category/**",
                        "/banner/**",
                        "/doc.html/**",
                        "/v3/api-docs/**",
                        "/plugins/**",
                        "/favicon.ico",
                        "/alipay/callback",
                        "/error"
                );
    }

}
